package com.ruoyi.system.service.impl.basic;

import java.util.List;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.basic.BasicMaterialsMapper;
import com.ruoyi.system.domain.db.basic.BasicMaterials;
import com.ruoyi.system.service.IBasicMaterialsService;

/**
 * 物资的类型Service业务层处理
 * 
 * @author sen
 * @date 2023-07-25
 */
@Service
public class BasicMaterialsServiceImpl implements IBasicMaterialsService 
{
    @Autowired
    private BasicMaterialsMapper basicMaterialsMapper;

    /**
     * 查询物资的类型
     * 
     * @param materialId 物资的类型主键
     * @return 物资的类型
     */
    @Override
    public BasicMaterials selectBasicMaterialsByMaterialId(Long materialId)
    {
        return basicMaterialsMapper.selectBasicMaterialsByMaterialId(materialId);
    }

    /**
     * 查询物资的类型列表
     * 
     * @param basicMaterials 物资的类型
     * @return 物资的类型
     */
    @Override
    public List<BasicMaterials> selectBasicMaterialsList(BasicMaterials basicMaterials)
    {
        return basicMaterialsMapper.selectBasicMaterialsList(basicMaterials);
    }

    /**
     * 新增物资的类型
     * 
     * @param basicMaterials 物资的类型
     * @return 结果
     */
    @Override
    public int insertBasicMaterials(BasicMaterials basicMaterials)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        basicMaterials.setCreateTime(DateUtils.getNowDate());
        basicMaterials.setUpdateBy(loginUser.getUser().getUserId());
        basicMaterials.setCreateBy(loginUser.getUser().getUserId());
        basicMaterials.setUpdateTime(DateUtils.getNowDate());
        basicMaterials.setIsDelete(0);
        return basicMaterialsMapper.insertBasicMaterials(basicMaterials);
    }

    /**
     * 修改物资的类型
     * 
     * @param basicMaterials 物资的类型
     * @return 结果
     */
    @Override
    public int updateBasicMaterials(BasicMaterials basicMaterials)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        basicMaterials.setUpdateTime(DateUtils.getNowDate());
        basicMaterials.setUpdateBy(loginUser.getUser().getUserId());
        return basicMaterialsMapper.updateBasicMaterials(basicMaterials);
    }

    /**
     * 批量删除物资的类型
     * 
     * @param materialIds 需要删除的物资的类型主键
     * @return 结果
     */
    @Override
    public int deleteBasicMaterialsByMaterialIds(Long[] materialIds)
    {
        return basicMaterialsMapper.deleteBasicMaterialsByMaterialIds(materialIds);
    }

    /**
     * 删除物资的类型信息
     * 
     * @param materialId 物资的类型主键
     * @return 结果
     */
    @Override
    public int deleteBasicMaterialsByMaterialId(Long materialId)
    {
        return basicMaterialsMapper.deleteBasicMaterialsByMaterialId(materialId);
    }
}
